package com.lottery.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lottery.server.entity.LotteryRecord;
import com.lottery.server.mapper.LotteryRecordMapper;
import com.lottery.server.service.LotteryRecordService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class LotteryRecordServiceImpl extends ServiceImpl<LotteryRecordMapper, LotteryRecord> implements LotteryRecordService {
    
    @Override
    public Object getRecords(Integer current, Integer size, String phone) {
        Page<LotteryRecord> page = new Page<>(current, size);
        QueryWrapper<LotteryRecord> queryWrapper = new QueryWrapper<>();
        
        if (StringUtils.hasText(phone)) {
            queryWrapper.eq("phone", phone);
        }
        
        queryWrapper.orderByDesc("create_time");
        return page(page, queryWrapper);
    }
} 